Skip to content

fix: implement missing utilities and fix edge-case bugs#209

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2472-1781495004
Open

fix: implement missing utilities and fix edge-case bugs#209
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2472-1781495004

Conversation

@stooit

@stooit stooit commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. The suite now passes 60/60 (was 44/60). No test files modified, no dependencies added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0 (previously returned Infinity).
  • src/string-utils.ts — implemented truncate (word-boundary aware, ellipsis counts toward maxLength, handles tiny limits) and fixed wordCount to split on \s+.
  • src/task-manager.ts — implemented the missing remove, update, and sortBy methods (remove/update return false for unknown ids; sortBy supports priority and createdAt ordering).
  • src/date-utils.ts — fixed off-by-one in formatRelative by using Math.round for the day count (36h → "2 days ago").
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts URLs with a port (e.g. http://localhost:3000).

Verification

  • bun test60 pass / 0 fail.
  • Independent review pass: all fixes confirmed as genuine general implementations (not hard-coded to tests); no regressions found.

Assumptions / notes

  • sortBy("status") uses alphabetical (localeCompare) ordering, as no explicit status order is specified by the tests.
  • truncate returns a raw slice without an ellipsis when maxLength <= ellipsis.length, matching the tiny-limit test expectations.

- calculator: divide now throws on division by zero
- string-utils: implement truncate (word-boundary, ellipsis-aware) and fix wordCount whitespace handling
- task-manager: implement remove, update, and sortBy
- date-utils: fix off-by-one in relative day rounding (Math.round)
- validator: accept long TLDs in isEmail and URLs with ports in isUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant